<!--!
This file is a part of MediaDrop (https://www.mediadrop.video),
Copyright 2009-2018 MediaDrop contributors
For the exact contribution history, see the git revision log.
The source code contained in this file is licensed under the GPLv3 or
(at your option) any later version.
See LICENSE.txt in the main project directory, for more information.
-->
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      py:strip="">

	<py:match path="head" once="true">
		<head>
			<meta py:replace="select('*|text()')" />
			<link href="${h.url_for('/styles/comments.css')}" media="screen" rel="stylesheet" type="text/css" />
		</head>
	</py:match>

	<py:def function="comment_li(comment)">
		<li class="comment">
			<div class="comment-top-divot"></div>
			<div class="comment-content clearfix">
				<span class="avatar"><img src="${h.gravatar_from_email(comment.author.email, 70)}" width="70" height="70" alt="" /></span>
				<cite>
					<a href="#comment-${comment.id}" name="comment-${comment.id}" class="underline-hover" title="Permalink"
					   py:with="datetime = h.format_datetime(comment.created_on)">
						<strong>${comment.author.name}</strong><br />
						<span class="comment-date" i18n:msg="datetime">said on ${datetime}&#8230;</span>
					</a>
				</cite>
				<blockquote py:content="Markup(comment.body)" />
			</div>
			<div class="comment-bottom" />
		</li>
	</py:def>

	<py:def function="comment_list(comments, action=None, values=None)">
		<div class="comments">
			<h2 class="comments-head">Comments</h2>
			<div py:if="not comments" class="no-comments" id="no-comments">
				<div class="comment-top-divot" />
				<div class="comment-content">No comments have been posted yet.</div>
				<div class="comment-bottom" />
			</div>
			<ul class="comments-list" id="comments-list">
				<py:for each="comment in comments">${comment_li(comment)}</py:for>
			</ul>
			<div id="comment-flash" class="no-comments" style="display:none">
				<div class="comment-top" />
				<div class="comment-content" />
				<div class="comment-bottom" />
			</div>
			<py:if test="action">
				<form id="post-comment-form" action="${action}" method="post" class="required form">
				<br />
				<h3>Write a comment</h3>
					<ul class="field-list" py:with="
						values = values or {};
						errors = tmpl_context.form_errors or {};
					">
						<li id="name-container" class="even" py:with="error = errors.get('name', None)">
							<div py:if="error" class="form-error">${error}</div>
							<div id="name-label" class="form-label">
								<label for="name">Name</label>
							</div>
							<div class="form-field">
								<input type="text" name="name" class="textfield required" id="name" value="${values.get('name', None)}" />
							</div>
						</li>
						<li id="email-container" class="odd" py:with="error = errors.get('email', None)">
							<div py:if="error" class="form-error">${error}</div>
							<div id="email-label" class="form-label">
								<label for="email">Email Address (will never be published)</label>
							</div>
							<div class="form-field">
								<input type="text" name="email" class="textfield" id="email" value="${values.get('email', None)}" maxlength="255" />
							</div>
						</li>
						<li id="body-container" class="even" py:with="error = errors.get('body', None)">
							<div py:if="error" class="form-error">${error}</div>
							<div id="body-label" class="form-label">
								<!--! XXX: This may not be a safe assumption for all languages... but for some reason 'Comment' alone doesn't translate here. -->
								<label for="body">${ungettext('Comment', 'Comments', 1)}</label>
							</div>
							<div class="form-field">
								<textarea id="body" name="body" class="required textarea" rows="5" cols="25">${values.get('body', None)}</textarea>
							</div>
						</li>
						<li id="submit-container" class="odd submit">
							<div class="form-field">
								<button type="submit" class="mcore-btn btn-post-comment f-rgt"><span>Submit Comment</span></button>
							</div>
						</li>
					</ul>
				</form>
			</py:if>
		</div>
	</py:def>

	<py:if test="value_of('comment_to_render', None)">
		${comment_li(comment_to_render)}
	</py:if>

</html>
